#include <bits/stdc++.h>
using namespace std;

int arr[105][105];
int main() {
    int n, m, count = 0;
    cin >> m >> n;
    for (int i = 1; i <= m; ++i)
        for (int j = 1; j <= n; ++j)
            cin >> arr[i][j];
    for (int i = 1; i <= m; ++i)
        for (int j = 1, tmp; j <= n; ++j) {
            cin >> tmp;
            count += (arr[i][j] == tmp);
        }
    printf("%.2f\n", ((count * 1.00) / (n * m * 1.00) * 100.00));
    return 0;
}